package com.neusoft.yuejian_01.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.neusoft.yuejian_01.activity.ProfessorDetailActivity;
import com.neusoft.yuejian_01.R;
import com.neusoft.yuejian_01.base.BaseAdapter;
import com.neusoft.yuejian_01.javabean.ProfessorBean;
import com.neusoft.yuejian_01.model.ConstPhoto;
import com.neusoft.yuejian_01.viewHolder.ProfessorViewHolder;

import java.util.List;

import it.sephiroth.android.library.picasso.Picasso;

/**
 * Created by Administrator on 2017/9/30.
 */

public class ProfessorAdapter extends BaseAdapter {
    public ProfessorAdapter(Context context, List data) {
        super(context, data);
        this.context = context;
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_professorlist,parent,false);
        ProfessorViewHolder viewHolder = new ProfessorViewHolder(itemView);
        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        ProfessorBean professorlist =(ProfessorBean) data.get(position);
        ProfessorViewHolder viewHolder = (ProfessorViewHolder) holder;
        String clubName = professorlist.getC_name();
        final String pm_name = professorlist.getPm_name();
        final int pm_id = professorlist.getPm_id();
        viewHolder.ClubNameView.setText(clubName);
        viewHolder.ProfessorNameView.setText(pm_name);
        String professorImage = ConstPhoto.BASE_URL+ConstPhoto.ProfessorFile+professorlist.getPm_pic();
        Picasso.with(context).load(professorImage).placeholder(R.drawable.pic2).into(viewHolder.ProfessorImage);
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //启动新的activity(大师详情)
                Intent intent = new Intent(context, ProfessorDetailActivity.class);
                intent.putExtra("pm_id", pm_id);
                intent.putExtra("pm_name",pm_name);
                context.startActivity(intent);
            }
        });
    }
}
